import { createStore, applyMiddleware } from 'redux';
import rootReducer from './reducers';
import createSagaMiddleware from '../redux-saga';
import rootSaga from './sagas';

// 创建saga中间件，dispatch时，发布put方法，继续往下执行
let sagaMiddleware = createSagaMiddleware();
// 创建store，传入中间件
let store = applyMiddleware(sagaMiddleware)(createStore)(rootReducer);
window.store = store;
// 启动saga，执行runSaga方法
sagaMiddleware.run(rootSaga);

export default store;
